package com.yunlan.materia.exceptions;

import com.yunlan.materia.entity.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 云澜
 * @date 2025/9/18
 * @ApiNote
 */
@ControllerAdvice
@ResponseBody
public class GlobalExceptionHandler {

    @ExceptionHandler(value = Exception.class)
    public Result exceptionHandler(HttpServletRequest request, Exception e){
        System.out.println("全局异常");
        return Result.error("服务端异常，请联系管理员"+"<br/>"+e.getMessage());
    }
}
